package com.senlingspace.payment.douyin.bean.request;

import com.alibaba.fastjson2.JSON;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.senlingspace.payment.douyin.DouyinFunctionEnum;
import com.senlingspace.payment.douyin.bean.response.DouyinVerifyTicketResponse;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 抖音验券
 *
 * @author lebronjames
 * @date 2024/07/23
 */
@Data
public class DouyinVerifyTicketRequest implements DouyinRequest<DouyinVerifyTicketResponse> {

    /**
     * 一次验券的标识 (用于短时间内的幂等)
     * 针对三方码订单，每次请求都需要保证幂等！（请求维度，非券码/订单维度）
     */
    @JsonProperty("verify_token")
    private String verifyToken;

    /**
     * 核销的抖音门店id
     */
    @JsonProperty("poi_id")
    private String poiId;

    /**
     * 验券准备接口返回的加密抖音券码
     * 多次卡商品，如果需要一次核销多份，list中传多个相同encrypted_code
     */
    @JsonProperty("encrypted_codes")
    private List<String> encryptedCodes = new ArrayList<>();


    @Override
    public DouyinFunctionEnum getFunction() {
        return DouyinFunctionEnum.verify_ticket;
    }

    @Override
    public String getBody() {
        DouyinVerifyTicketRequest request = new DouyinVerifyTicketRequest();
        request.setVerifyToken(this.verifyToken);
        request.setPoiId(this.poiId);
        request.setEncryptedCodes(this.encryptedCodes);
        return JSON.toJSONString(request);
    }

    @Override
    public Class<DouyinVerifyTicketResponse> getResponseType() {
        return DouyinVerifyTicketResponse.class;
    }
}
